Skip to content

fix(issue): showNextAction !ctx.hasUI guard misses headless RPC mode where hasUI is truthy but no human input is possible (next-action-ui.js:70)#6200

Merged
jeremymcs merged 1 commit into
mainfrom
issue/5742-shownextaction-ctx-hasui-guard-misses-he-1778905572
May 16, 2026
Merged

fix(issue): showNextAction !ctx.hasUI guard misses headless RPC mode where hasUI is truthy but no human input is possible (next-action-ui.js:70)#6200
jeremymcs merged 1 commit into
mainfrom
issue/5742-shownextaction-ctx-hasui-guard-misses-he-1778905572

Conversation

@jeremymcs
Copy link
Copy Markdown
Collaborator

@jeremymcs jeremymcs commented May 16, 2026

Summary

  • Replaced showNextAction’s hasUI-only guard with an interactivity guard that blocks headless/RPC prompting and verified via targeted unit tests.

Verification

  • Completed in the repository worktree before push.

Related Issue

Repo

  • gsd-build/gsd-2

Branch

  • issue/5742-shownextaction-ctx-hasui-guard-misses-he-1778905572

Summary by CodeRabbit

  • Bug Fixes

    • Improved interactive UI context detection to ensure consistent behavior in headless and RPC modes.
  • Tests

    • Added test coverage for UI mode validation scenarios.

Review Change Stack

…where hasUI is truthy but no human input is possible (next-action-ui.js:70)
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 16, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 8805645e-149c-4732-8b2f-d6c66caa472b

📥 Commits

Reviewing files that changed from the base of the PR and between 74bba52 and 906bdc2.

📒 Files selected for processing (2)
  • src/resources/extensions/shared/next-action-ui.ts
  • src/resources/extensions/shared/tests/next-action-ui-hasui.test.ts

📝 Walkthrough

Walkthrough

This PR fixes a bug where showNextAction incorrectly attempted interactive UI selection in headless RPC mode. A new isInteractiveUIContext predicate replaces the incomplete !ctx.hasUI guard, checking for environment headless mode and RPC/headless UI modes. A regression test validates that RPC mode correctly returns "not_yet" without invoking UI methods.

Changes

Interactive UI Context Guard

Layer / File(s) Summary
Interactive UI context guard and predicate
src/resources/extensions/shared/next-action-ui.ts
showNextAction early return is updated from if (!ctx.hasUI) to if (!isInteractiveUIContext(ctx)). New isInteractiveUIContext helper returns false when ctx.hasUI is false, GSD_HEADLESS environment variable is "1", or ctx.ui.mode is "rpc" or "headless".
Regression test for RPC mode non-interactivity
src/resources/extensions/shared/tests/next-action-ui-hasui.test.ts
New test case constructs a context with hasUI: true and ui.mode: "rpc", asserts showNextAction returns "not_yet" immediately, and verifies neither ctx.ui.custom nor ctx.ui.select is called.

🎯 2 (Simple) | ⏱️ ~8 minutes

A guard stands watch at the gate,
No longer fooled by RPC's sleight,
When headless comes, it knows its fate,
Returns "not_yet" — safe and bright. 🐰✨

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR addresses the primary fix but does not fully complete the linked issue scope, which requires auditing and updating 8 other callers across forensics.js, skill-catalog.js, guided-flow.js, guided-flow-queue.js, and triage-ui.js. Complete the audit of remaining callers (forensics.js, skill-catalog.js, guided-flow.js, guided-flow-queue.js, triage-ui.js and others) and replace ctx.hasUI-based early returns with the new isInteractiveUIContext predicate as specified in issue #5742.
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately describes the main change: replacing a faulty ctx.hasUI guard with a proper isInteractiveUIContext guard in showNextAction to handle headless RPC mode.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing the showNextAction guard and adding regression tests as specified in the linked issue.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch issue/5742-shownextaction-ctx-hasui-guard-misses-he-1778905572

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown
Contributor

🟢 PR Risk Report — LOW

Files changed 2
Systems affected 0
Overall risk 🟢 LOW

@jeremymcs jeremymcs merged commit 6c9a50f into main May 16, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

showNextAction !ctx.hasUI guard misses headless RPC mode where hasUI is truthy but no human input is possible (next-action-ui.js:70)

1 participant